﻿@model ThienVienDiDaTu.Models.TinTuc

@{
    ViewBag.Title = "Soạn thảo tin";
}

<h2>Soạn thảo tin</h2>


@using (Html.BeginForm("NewsEdit", "Admin", FormMethod.Post, new { @enctype = "multipart/form-data" }))
{
    @Html.ValidationSummary(true)
    <fieldset>
        <legend>TinTuc</legend>
        @*<div class="editor-label">
            @Html.LabelFor(model => model.LoaiTin)
        </div>*@
        
        @*<div class="editor-field">
            @Html.DropDownList("ChonNhomTin", new SelectList(ViewBag.listNt))
            
        </div>*@
        <div class="editor-field">
            @Html.DropDownListFor(m=>m.LoaiTinID, ViewBag.listNt as IEnumerable<SelectListItem>)
            
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.NhanDe)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.NhanDe)
            @Html.ValidationMessageFor(model => model.NhanDe)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.TomTat)
        </div>
        <div class="editor-field">
            @Html.TextAreaFor(model => model.TomTat)
            @Html.ValidationMessageFor(model => model.TomTat)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.NoiDung)
        </div>
        <div class="editor-field">
            @Html.TextAreaFor(model => model.NoiDung)
            @Html.ValidationMessageFor(model => model.NoiDung)
        </div>

        <br/>
        @Html.HiddenFor(model=>model.LinkAnh)

        <img src=@("/Content/data/images/"+Model.LinkAnh) alt="an image" class="image" height="150px" width="200px">

        <div class="editor-label">
            Link ảnh mới: @Microsoft.Web.Helpers.FileUpload.GetHtml( initialNumberOfFiles: 1, allowMoreFilesToBeAdded: false, includeFormTag: false, addText: "Thêm ảnh", uploadText: "Upload ảnh")
        </div>

        <p>
            <input type="submit" value="Save" />
        </p>
    </fieldset>
}

<div>
    @Html.ActionLink("Quay lại danh sách tin", "NewsList")
</div>

<script type="text/javascript" id="oi">
    $(document).ready(function () {
        function UpdateCKEditors() {
            $('NoiDung').ckeditorGet().updateElement();
        }

        CKEDITOR.replace('NoiDung',
        {
            filebrowserImageUploadUrl: '/Admin/UploadImage',
            filebrowserUploadUrl: '/Admin/UploadImage'
        });

       

    });
</script>